#include<iostream>
using namespace std;

int main(){
    int pencil = 0;
    cin>>pencil;
    int bag1_num,price1;
    int bag2_num,price2;
    int bag3_num,price3;
    cin>>bag1_num>>price1;
    cin>>bag2_num>>price2;
    cin>>bag3_num>>price3;

    if(pencil > 10000 || bag1_num > 10000 || bag2_num > 10000 || bag3_num >10000 || price1 > 10000 || price2 > 10000 || price3 > 10000){
        return -1;
    }
    int ret,ret2,ret3;
    //除不尽的时候才要多买，除的尽就不用多买
     if(pencil % bag1_num){
        //除不尽
         ret = (pencil / bag1_num +1) *price1;
     }else{
         ret = (pencil / bag1_num) * price1;
     }

     if(pencil % bag2_num){
        //除不尽
         ret2 = (pencil / bag2_num +1) *price2;
     }else{
         ret2 = (pencil / bag2_num) * price2;
     }

     if(pencil % bag3_num){
        //除不尽
         ret3 = (pencil / bag3_num +1) *price3;
     }else{
         ret3 = (pencil / bag3_num) * price3;
     }



    //找出最小值打印即可
    int tmp = ret < ret2 ? ret : ret2;
    int tmp2 = tmp < ret3 ? tmp : ret3;

    cout<<tmp2<<endl;


    return 0;
}